package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysMonitorInfo;
import com.ruoyi.system.service.ISysMonitorInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 摄像头管理Controller
 * 
 * @author ruoyi
 * @date 2021-04-04
 */
@RestController
@RequestMapping("/system/monitorInfo")
public class SysMonitorInfoController extends BaseController
{
    @Autowired
    private ISysMonitorInfoService sysMonitorInfoService;

    /**
     * 查询摄像头管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:monitorInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysMonitorInfo sysMonitorInfo)
    {
        startPage();
        List<SysMonitorInfo> list = sysMonitorInfoService.selectSysMonitorInfoList(sysMonitorInfo);
        return getDataTable(list);
    }

    /**
     * 导出摄像头管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:monitorInfo:export')")
    @Log(title = "摄像头管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SysMonitorInfo sysMonitorInfo)
    {
        List<SysMonitorInfo> list = sysMonitorInfoService.selectSysMonitorInfoList(sysMonitorInfo);
        ExcelUtil<SysMonitorInfo> util = new ExcelUtil<SysMonitorInfo>(SysMonitorInfo.class);
        return util.exportExcel(list, "monitorInfo");
    }

    /**
     * 获取摄像头管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:monitorInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(sysMonitorInfoService.selectSysMonitorInfoById(id));
    }

    /**
     * 新增摄像头管理
     */
    @PreAuthorize("@ss.hasPermi('system:monitorInfo:add')")
    @Log(title = "摄像头管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysMonitorInfo sysMonitorInfo)
    {
        return toAjax(sysMonitorInfoService.insertSysMonitorInfo(sysMonitorInfo));
    }

    /**
     * 修改摄像头管理
     */
    @PreAuthorize("@ss.hasPermi('system:monitorInfo:edit')")
    @Log(title = "摄像头管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysMonitorInfo sysMonitorInfo)
    {
        return toAjax(sysMonitorInfoService.updateSysMonitorInfo(sysMonitorInfo));
    }

    /**
     * 删除摄像头管理
     */
    @PreAuthorize("@ss.hasPermi('system:monitorInfo:remove')")
    @Log(title = "摄像头管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysMonitorInfoService.deleteSysMonitorInfoByIds(ids));
    }
}
